const path = require('path');


const HtmlWebpackPlugin = require('html-webpack-plugin');
var htmlPlugin = new HtmlWebpackPlugin({
	template:path.join(__dirname,'./src/index.html'),
	filename:'index.html'
});

//vue-loader需要配置插件
const { VueLoaderPlugin } = require('vue-loader');
var vueLoaderPlugin = new VueLoaderPlugin();

module.exports = {
	entry:path.join(__dirname,'./src/main.js'),
	output:{
		path:path.join(__dirname,'./dist'),
		filename:'bundle.js'
	},
	plugins:[htmlPlugin,vueLoaderPlugin],
	
	module:{
		rules:[
		    {test:/\.vue$/,use:'vue-loader'},
			{test:/\.css$/,use:['style-loader','css-loader']},
			{test:/\.less$/,use:['style-loader','css-loader','less-loader']},
			{test:/\.scss$/,use:['style-loader','css-loader','sass-loader']},
			{test:/\.(jpg|png|gif|bmp|jpeg)$/,use:['url-loader?limit=1000&name=[hash:8]-[name].[ext]']},
			{test:/\.(eot|svg|ttf|woff|woff2)$/,use:'url-loader'},
											
			//babel处理 webpack处理不了的  ES6 ES7 语法的js文件  								
			{test:/\.js$/,use:'babel-loader',exclude:[/node_modules/,
				//防止babel错误的处理首页 因为首页被放入内存中时可能会生成.js的文件
			   require.resolve(path.join(__dirname,'./src/index.html'))]},	


		]
	},

	resolve:{
		alias:{
			// "vue$": "vue/dist/vue.js"
		}
	}
}